package landx.toolkit.utils
{
	import landx.toolkit.StringBuilder;

	public class DateTimeUtil
	{
		/**
		 * 获取格式化时间函数 
		 * @param date	需要格式化的时间
		 * @param format	格式化参数 yyyy-mm-dd hh:MM:ss
		 * @return 
		 */		
		public static function format(date:Date,format:String):String{
			format=StringUtil.replace(format,"yyyy",StringUtil.replenish(date.fullYear,4));
			format=StringUtil.replace(format,"yy",StringUtil.replenish(date.fullYear,2));
			format=StringUtil.replace(format,"mm",StringUtil.replenish(date.month+1,2));
			format=StringUtil.replace(format,"dd",StringUtil.replenish(date.day,2));
			format=StringUtil.replace(format,"hh",StringUtil.replenish(date.hours,2));
			format=StringUtil.replace(format,"MM",StringUtil.replenish(date.minutes,2));
			format=StringUtil.replace(format,"ss",StringUtil.replenish(date.seconds,2));
			return format;
		}
		
		/**
		 * 获取当前时间 
		 * @return 当前时间
		 */		
		public static function now():Date{
			return new Date();
		}
	}
}